package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.UserInfo;
import cn.wolfcode.wolf2w.service.IUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/users")
public class UserController {
    @Autowired
    private IUserInfoService userInfoService;
    @GetMapping("/saveOrUpdate")
    public void saveOrUpdate(UserInfo user){
        if (StringUtils.hasLength(user.getId())){
            userInfoService.update(user);
        }else {
            userInfoService.save(user);
        }
    }

}
